from flask_restful import fields


book_fields = {
    'id':fields.Integer,
    'name':fields.String,
    'price':fields.Float,
    'author_id':fields.Integer,
    'author':fields.Nested({  #关系字段
        'id':fields.Integer,
        'name':fields.String,
        'address':fields.String,
        'phone':fields.String
    })
}

author_fields ={
    'id':fields.Integer,
    'name':fields.String,
    'books':fields.List(fields.Nested({#关系字段
        'id':fields.Integer,
        'name':fields.String,
        'price':fields.Float
    }))
}